package com.example.shopping_mall.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.shopping_mall.R;
import com.example.shopping_mall.bean.LocationData;
import com.example.shopping_mall.bean.MineOrder;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: Shopping_Mall
 * @Package: com.example.shopping_mall.adapter
 * @ClassName: MineOrderAdapter
 * @Description: 地址adapter
 * @Author: 作者名
 * @CreateDate: 2022-11-04 0:33
 * @UpdateUser: 更新者：
 **/
public class MineLocationAdapter extends RecyclerView.Adapter<MineLocationAdapter.MyHodel> {

    private List<LocationData> list;

    private Context context;

    public MineLocationAdapter(List<LocationData> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public MineLocationAdapter.MyHodel onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyHodel(LayoutInflater.from(context).inflate(R.layout.mine_item_location, null));
    }

    @Override
    public void onBindViewHolder(MineLocationAdapter.MyHodel holder, int position) {
        holder.minename.setText(list.get(position).getName());
        holder.minephone.setText(list.get(position).getPhone());
        holder.minediz.setText(list.get(position).getProvince() + list.get(position).getCity() + list.get(position).getRegion() + list.get(position).getDetailAddress());

    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class MyHodel extends RecyclerView.ViewHolder {
        TextView minename;
        TextView minephone;
        TextView minediz;

        public MyHodel(View itemView) {
            super(itemView);
            minename = itemView.findViewById(R.id.minename);
            minephone = itemView.findViewById(R.id.minephone);
            minediz = itemView.findViewById(R.id.minediz);

        }
    }
}
